#include "StdAfx.h"
#include "RootOperator.h"


RootOperator::RootOperator(void)
{
}


RootOperator::~RootOperator(void)
{
}
void RootOperator::execution(int executionTimes)
{
#ifdef DEBUG
	std::cout<<"===================operator begin================="<<std::endl;
	std::cout<<"operatorid : "<<this->getId()<<std::endl;
#endif
	assert(this->getInputQueueList().size()==1);
	boost::shared_ptr<QueueEntity>inputQueue = this->getInputQueueList().front();
	for(int i = 0 ;i<executionTimes ;i++)
	{
		if(inputQueue->isEmpty())
		{
			break;
		}
		if(this->streamOutput->isFull())
		{
			break;
		}
		Element inputElement;
		inputQueue->dequeue(inputElement);
		this->streamOutput->pushNext(inputElement);
//		std::cout<<inputElement<<std::endl;
	}
#ifdef DEBUG
	std::cout<<"===================operator over================="<<std::endl;
#endif
}

void RootOperator::setStreamOutput(boost::shared_ptr<IStreamOutput> streamOutput)
{
	this->streamOutput = streamOutput;
	this->streamOutput->initial();
}